﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using strange.extensions.mediation.impl;

public class CharacterView : View {

    public PlayerController Player;
    public ComputerController LeftComputer;
    public ComputerController RightComputer;
    public DeskController Desk;

    /// <summary>
    /// 发牌
    /// </summary>
    /// <param name="cType">给哪个角色添加</param>
    /// <param name="card">添加哪张卡牌</param>
    /// <param name="Selected">是否被选中</param>
    public void AddCard(CharacterType cType, Card card, bool Selected)
    {
        switch (cType)
        {
            case CharacterType.Player:
                Player.AddCard(card,Selected);
                break;
            case CharacterType.ComputerLeft:
                LeftComputer.AddCard(card, Selected);
                break;
            case CharacterType.ComputerRight:
                RightComputer.AddCard(card, Selected);
                break;
            case CharacterType.Desk:
                Desk.AddCard(card, Selected);
                break;
            default:
                break;
        }
    }
    /// <summary>
    /// 发三张底牌
    /// </summary>
    /// <param name="cType"></param>
    public void AddThreeCard(CharacterType cType)
    {
        Card card = null;
        switch (cType)
        {
            case CharacterType.Player:
                for (int i = 0; i < 3; i++)
                {
                    card = Desk.DealCard();
                    Player.AddCard(card, true);
                }
                Player.Identity = Identity.Landlord;
                Player.Sort(false);
                break;
            case CharacterType.ComputerRight:
                for (int i = 0; i < 3; i++)
                {
                    card = Desk.DealCard();
                    RightComputer.AddCard( card, false);
                }
                RightComputer.Identity = Identity.Landlord;
                RightComputer.Sort(true);
                break;
            case CharacterType.ComputerLeft:
                for (int i = 0; i < 3; i++)
                {
                    card = Desk.DealCard();
                    LeftComputer.AddCard(card, false);
                }
                LeftComputer.Identity = Identity.Landlord;
                LeftComputer.Sort(true);
                break;
            default:
                break;
        }
        //发完牌清空桌面
        Desk.ClearDesk();
    }
}
